package com.lenovo.newsapp.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ArrayAdapter;

public class BaseArrayAdapter<T> extends ArrayAdapter<T> {

	final public LayoutInflater mInflater;
	View parentView;
	Context context;
	ArrayList<T> dataList;

	public BaseArrayAdapter(Context context, ArrayList<T> resultList,
			View parentView) {
		super(context, android.R.layout.simple_list_item_1, resultList);
		this.dataList = resultList;
		this.context = context;
		mInflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		this.parentView = parentView;
	}

	
	public void appendOlder(ArrayList<T> resultList) {
		setNotifyOnChange(true);
		for (T result : resultList) {
			add(result);
		}
		notifyDataSetChanged();
	}

	
	public void refreshData(ArrayList<T> resultList) {
		clear();
		dataList = resultList;
		setNotifyOnChange(true);
		for (T result : resultList) {
			add(result);
		}
		notifyDataSetChanged();
	}
	
	public ArrayList<T> getAllItems() {
		return dataList;
	}


}
